package com.hut.oa.model.bean;

import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.Table;

/**
 * 角色管理表
 * @author 潘寻毅
 *
 */
@Entity
@Table(name = "role_")
public class Role {
	
	@Id
	@GeneratedValue(strategy=GenerationType.IDENTITY)
	@Column(name="r_id")
	private Long id;//角色id
	
	@Column(name="r_name",nullable=false)
	private String name;//角色名称
	
	@Column(name="r_describe")
	private String describe;//角色描述
	
	@Column(name="r_power_value")
	private Integer powerValue;//权限值
	
	@ManyToMany(fetch = FetchType.LAZY)
	@JoinTable(name="role_menu",
	joinColumns={
			@JoinColumn(name="rm_role_id")
	},inverseJoinColumns={
			@JoinColumn(name="rm_menu_id")
	})
	private List<Menu> menus;//菜单
	
	/*@ManyToMany(fetch = FetchType.LAZY,cascade=CascadeType.ALL)
	@JoinTable(name="role_operate",
	joinColumns={
			@JoinColumn(name="rm_role_id")
	},inverseJoinColumns={
			@JoinColumn(name="rm_operate_id")
	})
	private List<Operate> operates;//操作资源
*/
	public Role() {
		super();
		// TODO Auto-generated constructor stub
	}

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getDescribe() {
		return describe;
	}

	public void setDescribe(String describe) {
		this.describe = describe;
	}

	public Integer getPowerValue() {
		return powerValue;
	}

	public void setPowerValue(Integer powerValue) {
		this.powerValue = powerValue;
	}

	public List<Menu> getMenus() {
		return menus;
	}

	public void setMenus(List<Menu> menus) {
		this.menus = menus;
	}

	@Override
	public String toString() {
		return "Role [id=" + id + ", name=" + name + ", describe=" + describe + ", powerValue=" + powerValue + "]";
	}
	
}
